// load video in slot
function videoCue(video, slot, startseconds) {	
	printLog('Preparing cue of video ' + video + ' in slot ' + slot);
	vidCueing[slot] = true;
	vid[slot].mute();
	videoLoad(video, slot, startseconds);
	// cue continues in ytdj.state.js
}

function videoLoad(video, slot, startseconds) {
	printLog('Load video ' + video + ' in slot ' + slot);
	vid[slot].loadVideoById(video, startseconds);
	vid[slot].vidId = video;
	setTitle(video, slot);
}

// goto position in % in video
function videoGotoPerc(perc, slot) {
	printLog('Goto position ' + perc +'% in slot '+slot);
	vid[slot].seekTo(parseInt(parseInt(vid[slot].getDuration())/100*perc), true);
}

// goto position in sec in video
function videoGotoSec(sec, slot) {
	printLog('Goto position ' + sec +' sec in slot '+slot);
	vid[slot].seekTo(parseInt(sec), true);
}

// pause video
function videoPause(slot) {
	printLog('Pause video in slot ' + slot);
	vid[slot].pauseVideo();
}

// play video
function videoPlay(slot) {
	printLog('Play video in slot ' + slot);
	vid[slot].playVideo();
}

// stop video
function videoStop(slot) {
	vid[slot].stopVideo();
}

// set volume
function videoVolume(slot, volume) {
	if (volume) {
		vidVolume[slot] = volume;
	}
	// calculate volume
	faderForSlot = slot == 1 ? Math.min(faderPos * 2, 100) : Math.min((100 - faderPos) * 2, 100);
	volumeForSlot = faderForSlot * vidVolume[slot] / 100;
	printLog('Set volume of video in slot '+slot+' to '+parseInt(volumeForSlot)+'%')
	vid[slot].setVolume(parseInt(volumeForSlot));
}

function videoTogglePlay(slot) {
	if (vidState[slot] == 1) {
		videoPause(slot);
	} else {
		videoPlay(slot);
	}
}